import sys
sys.path.append('/Users/cclarke/pytic')
import unittest
import TSCalendar as tscal
from datetime import datetime
from dateutil.parser import parse

class NormalizeDateTestCase(unittest.TestCase):
    def setUp(self):
        self.dd=datetime.now()
    def testDailyDate(self):
         ndd= tscal.normalize_date(datein=self.dd,date_type=tscal.Daily)
         oth_attr=ndd.hour+ndd.second+ndd.microsecond
         
         self.failUnless(oth_attr == 0)
    def testWeeklyDate(self):
        for w in (1,2,3,4):
            ndd= tscal.normalize_date(datein=self.dd,date_type=tscal.Weekly,weekday=w)
            oth_attr=ndd.hour+ndd.second+ndd.microsecond
            self.failUnless(oth_attr == 0)
            self.failUnless(ndd.weekday() == w)
    def testBusiness(self):
        """
        weekend dates should be pushed to the next monday
        """
        weekend = parse("2007-02-03")
        ndd= tscal.normalize_date(datein=weekend,date_type=tscal.Business)
        oth_attr=ndd.hour+ndd.second+ndd.microsecond
        print ndd
        self.failUnless(oth_attr == 0)
        self.failUnless(ndd.weekday() == 0)
            
if __name__ == '__main__':
   unittest.main()  